package com.cps.framecommon.exception;


import com.cps.framecommon.constant.enums.ErrorCodeEnums;
import com.cps.framecommon.constant.enums.ResponseEnum;
import com.cps.framecommon.response.Response;
import lombok.Getter;

/**
 * 业务异常类
 */
@Getter
public class BusinessException extends ErrorCodeException {

    public BusinessException(int code, String message) {
        super(code, message);
    }

    public BusinessException(ErrorCodeEnums errorCodeEnums) {
        super(errorCodeEnums.getCode(), errorCodeEnums.getMessage());
    }

    public BusinessException(String message) {
        super(Response.FAIL_CODE, message);
    }

    public BusinessException(ResponseEnum responseEnum) {
        super(responseEnum.getCode(), responseEnum.getMessage());
    }

    public static BusinessException of(ErrorCodeEnums errorCodeEnums) {
        return new BusinessException(errorCodeEnums);
    }

    public static BusinessException of(String message) {
        return new BusinessException(message);
    }
}
